<template>
    <div class="page-container" :style="styles">
        <iframe id="pdfviewer" :src="pdfUrl" frameborder="0"></iframe>
    </div>
</template>


<script>
import { buildPDFPreviewUrl } from '../utils'
export default {
    props: {
        styles: {
            type: Object,
            default: () => {
                return {};
            }
        },
        viewerBoutton:{
            type: Object,
            default: () => {
                return {
                    lrmxDownload: false,
                    pdfDownload: false,
                    wordDownload: false,
                };
            }
        }
    },
    components: {},
    data() {
        return {
            //文件URL
            pdfUrl: "",
        };
    },
    methods: {
        /**
         * 获取文件
         */
        render(P_FileUrl,P_FileName,P_Params) {
            P_Params.file = P_FileUrl;
            P_Params.filename = P_FileName || "";
            let httpUrl = localStorage.getItem("local_server_ip") || window.HC_config.VUE_APP_BASE_API || process.env.VUE_APP_BASE_API
            if(P_Params.lrmxUrl){
                P_Params.lrmxUrl = httpUrl + P_Params.lrmxUrl;
            }
            if(P_Params.wordUrl){
                P_Params.wordUrl = httpUrl + P_Params.wordUrl;
            }
            this.pdfUrl = buildPDFPreviewUrl(P_Params);//
        },
    },
}
</script>

<style lang="scss" scoped>
.page-container {
    width: 100%;
    iframe{
        width: 100%; 
        height: 100%;
    }
}
.loading-container {
    flex: 1;
    width: initial;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
</style>